package com.woniuxy.food.app.apiImpl;

import cn.hutool.core.bean.BeanUtil;
import com.woniuxy.cloud.mall95.log.Log;
import com.woniuxy.food.client.foodtypeclient.FoodTypeManageClient;
import com.woniuxy.food.client.param.InsertFoodTypeParam;
import com.woniuxy.food.client.param.UpdateFoodTypeParam;
import com.woniuxy.food.client.param.UpdateFoodTypeStateParam;
import com.woniuxy.food.service.FoodTypeService;
import com.woniuxy.food.service.serviceparam.InsertFoodTypeServiceParam;
import com.woniuxy.food.service.serviceparam.UpdateFoodTypeServiceParam;
import com.woniuxy.food.service.serviceparam.UpdateFoodTypeStateServiceParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import result.Result;

@RestController
@Slf4j
public class FoodTypeManageClientApiImpl implements FoodTypeManageClient {
    @Autowired
    private FoodTypeService foodTypeService;
    @Override
    @Log("添加菜品类型")
    public Result insertFoodType(InsertFoodTypeParam param) {
        InsertFoodTypeServiceParam insertFoodTypeServiceParam = BeanUtil.toBean(param, InsertFoodTypeServiceParam.class);
        foodTypeService.insertFoodType(insertFoodTypeServiceParam);
        return Result.success();
    }

    @Override
    @Log("菜品类型上下架")
    public Result updateFoodTypeByIds(UpdateFoodTypeStateParam param) {
        UpdateFoodTypeStateServiceParam updateFoodTypeStateServiceParam = BeanUtil.toBean(param, UpdateFoodTypeStateServiceParam.class);
        foodTypeService.updateFoodTypeStateByIds(updateFoodTypeStateServiceParam);
        return Result.success();
    }

    @Override
    @Log("菜品类型修改")
    public Result updateFoodTypeById(UpdateFoodTypeParam param) {
        UpdateFoodTypeServiceParam updateFoodTypeServiceParam = BeanUtil.toBean(param, UpdateFoodTypeServiceParam.class);
        foodTypeService.updateFoodTypeById(updateFoodTypeServiceParam);
        return Result.success();
    }

    @Override
    @Log("根据ID删除菜品类型")
    public Result deleteFoodTypeByIds(Integer[] ids, Integer storeId) {
        foodTypeService.deleteFoodTypeByIds(ids,storeId);
        return Result.success();
    }
}
